#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
class QLabel;
class Spreadsheet;
class FindDialog;
namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();
private slots:
    void about();
    void open();
    bool save();
    bool saveAs();
    void openRecentFile();
    void newFile();
    void gotoCell();
    void updateStatusBar();
    void spreadsheetModified();
    void find();
    void sort();
protected:
    void closeEvent(QCloseEvent *event);

private:
    void connectActions();
    void createStatusBar();
    bool okToContinue();
    bool loadFile(const QString &fileName);
    bool saveFile(const QString &fileName);
    void setCurrentFile(const QString &fullFileName);
    QString strippedName(const QString &fullFileName);
    void readSettings();
    void writeSettings();
    void createRecentFileActions();
    void createRecentFileMenus();
    void updateRecentFileActions();
    void createContextMenu();

private:
    Ui::MainWindow *ui;
    QLabel * locationLabel;
    QLabel * formulaLabel;
    Spreadsheet *spreadsheet;
    FindDialog *findDialog;

    QString curFile;
    enum{MaxRecentFiles=5};
    QAction* recentFileActions[MaxRecentFiles];
    QAction* separatorAction;
    QStringList recentFiles;
};

#endif // MAINWINDOW_H
